# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libraw
pkgver=0.21.3
pkgrel=0
pkgdesc="Library for reading RAW files obtained from digital photo cameras"
url="https://www.libraw.org/"
arch="all"
license="CDDL-1.0 OR LGPL-2.1-only"
makedepends="lcms2-dev"
subpackages="$pkgname-dev $pkgname-tools"
source="https://www.libraw.org/data/LibRaw-$pkgver.tar.gz"
builddir="$srcdir"/LibRaw-$pkgver
options="!check" # no tests

# secfixes:
#   0.21.1-r2:
#     - CVE-2023-1729
#   0.20.0-r0:
#     - CVE-2020-24890
#     - CVE-2020-24899
#     - CVE-2020-35530
#     - CVE-2020-35531
#     - CVE-2020-35532
#     - CVE-2020-35533
#     - CVE-2020-35534
#     - CVE-2020-35535
#   0.19.5-r1:
#     - CVE-2020-15503
#   0.19.2-r0:
#     - CVE-2018-20363
#     - CVE-2018-20364
#     - CVE-2018-20365
#     - CVE-2018-5817
#     - CVE-2018-5818
#     - CVE-2018-5819
#   0.18.6-r0:
#     - CVE-2017-16910
#   0.18.5-r0:
#     - CVE-2017-13735
#     - CVE-2017-14265

prepare() {
	default_prepare
	update_config_sub
}

build() {
	# trading size for more speed
	CFLAGS="$CFLAGS -O3 -flto=auto" \
	CXXFLAGS="$CXXFLAGS -O3 -flto=auto" \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--disable-static \
		--enable-openmp
	make
}

package() {
	make DESTDIR="$pkgdir" install
	rm -rf "$pkgdir"/usr/share/doc/
}

tools() {
	pkgdesc="tools for LibRaw"
	amove usr/bin
}

sha512sums="
c83363cdf5619f069affc9473ab3ea6560f67e72ab5e7bf6eefcf6a23521a729c9d417f323c4cc6679780c0536e5804390c243cace8a40341a0c5f26865d6a2d  LibRaw-0.21.3.tar.gz
"
